Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
WIP Themeable UI components for themes
css
propnpm i theme-ui
Wrap your application with the ThemeProvider
component
// basic usage
import React from 'react'
import { ThemeProvider } from 'theme-ui'
import theme from './theme'
export default props =>
<ThemeProvider theme={theme}>
{props.children}
</ThemeProvider>
css
propUse the css
prop in your application, along with the css
utility to pick up values from the theme.
The css
utility is from @styled-system/css.
import React from 'react'
import { css } from 'theme-ui'
export default () =>
<div
css={css({
fontSize: 4,
fontWeight: 'bold',
color: 'primary', // picks up values from theme
})}>
Hello
</div>
Use the components
prop to add components to MDX scope.
The ThemeProvider
is a combination of MDXProvider
and Emotion's ThemeProvider
.
// with mdx components
import React from 'react'
import { ThemeProvider } from 'theme-ui'
import mdxComponents from './mdx-components'
import theme from './theme'
export default props =>
<ThemeProvider
components={mdxComponents}
theme={theme}>
{props.children}
</ThemeProvider>
This will render child MDX documents with the components provided via context. For use outside of MDX (e.g. Remark Markdown) the styles could be applied with a wrapper component.
theme.styles
The MDX components can also be styled via the theme.styles
object.
This can be used as a mechanism to pass Typography.js-like styles to MDX content.
// example theme
export default {
colors: {
primary: '#33e',
},
styles: {
// this styles child MDX `<h1>` components
h1: {
fontSize: 32,
// this value comes from the `color` object
color: 'primary',
},
}
}
These components' styles can also be consumed outside of an MDX doc with the Styled
component.
Note that these are only styled using the same theme.styles
object and not the same components passed to the ThemeProvider
context.
import React from 'react'
import { Styled } from 'theme-ui'
export default props =>
<Styled.div>
<Styled.h1>
Hello
</Styled.h1>
</Styled.div>
To change the underlying component in Styled
, use the as
prop.
<Styled.a as={Link} to='/'>Home</Styled.a>
Theme UI includes several components for creating page layouts.
Layout
: sets a flex column with 100vh min-heightHeader
: flexbox rowFooter
: flexbox rowMain
: flex auto container for pushing the Footer to the bottom of the viewportContainer
: max-width, centered containerimport React from 'react'
import {
Layout,
Header,
Main,
Container,
Footer
} from 'theme-ui'
export default props =>
<Layout>
<Header>
Hello
</Header>
<Main>
<Container>
{props.children}
</Container>
</Main>
<Footer>
© 2019
</Footer>
</Layout>
The Box
& Flex
layout components are similar to the ones found in Rebass, but are built with Emotion and @styled-system/css
.
import React from 'react'
import { Flex, Box } from 'theme-ui'
export default props =>
<Flex flexWrap='wrap'>
<Box width={[ 1, 1/2 ]} />
<Box width={[ 1, 1/2 ]} />
</Flex>
MIT License
FAQs
The Design Graph Framework
The npm package theme-ui receives a total of 21,147 weekly downloads. As such, theme-ui popularity was classified as popular.
We found that theme-ui demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.